package com.SMP.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.SMP.dao.ManagerRoleMapper;
import com.SMP.model.ManagerRoleKey;

@Service
public class ManagerRoleService {
	
	/**
	 * @author WYHY
	 * 角色管理mapper
	 * */
	@Autowired
	ManagerRoleMapper managerRoleMapper;
	
	/**
//	 * @param 给管理员添加/修改角色
	 * @author WYHY
	 * */
	public int roleToManager(String managerid,List roleid) {
		int a=0;
		managerRoleMapper.deleteByManagerid(managerid);
		for (int i = 0; i < roleid.size(); i++) {
			String r=String.valueOf(roleid.get(i));
			ManagerRoleKey managerRole=new ManagerRoleKey();
			managerRole.setManagerid(Integer.parseInt(managerid));
			managerRole.setRoelid(Integer.parseInt(r));
			managerRoleMapper.insert(managerRole);
			a++;
		}
		return a;
	}
	
	/**
//	 * @param 管理员查询角色
	 * @author WYHY
	 * */
	public List managerSelRole(String managerid) {
		 List list=managerRoleMapper.selectByManagerid(Integer.parseInt(managerid));
		 return list;
	}

}
